getToken();
let user = JSON.parse(window.localStorage.getItem("userInfo"));
let links = server + `/?userId=${user.id}`;
$("#codeSave").click(function () {
  $("#codeSave").attr("data-clipboard-text", links);
  var btn = document.getElementById("codeSave");
  var clipboard = new ClipboardJS(btn);
  clipboard.on("success", function (e) {
    console.log(e);
    mui.alert("保存成功!");
    clipboard.destroy();
  });

  clipboard.on("error", function (e) {
    console.log(e);
    mui.alert("保存失败!");
    clipboard.destroy();
  });
});

$("#InvitationCode").click(function () {
  $("#InvitationCode").attr("data-clipboard-text", links);
  var btn = document.getElementById("InvitationCode");
  var clipboard = new ClipboardJS(btn);
  clipboard.on("success", function (e) {
    console.log(e);
    mui.alert("保存成功!");
    clipboard.destroy();
  });

  clipboard.on("error", function (e) {
    console.log(e);
    mui.alert("复制失败!");
    clipboard.destroy();
  });
});

var code = new QRCode(document.getElementById("code"), {
  text: serverApp + `/app/register.html?userId=${user.id}`,
});
